package com.caipu.controller;

import com.caipu.common.Result;
import com.caipu.service.DataInitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/init")
@CrossOrigin
public class InitController {
    
    @Autowired
    private DataInitService dataInitService;
    
    @PostMapping("/data")
    public Result<Void> initData() {
        try {
            dataInitService.initData();
            return Result.success();
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("数据初始化失败: " + e.getMessage());
        }
    }
}